<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <script type="text/javascript">
                function printDiv(divName) {
                    var printContents = document.getElementById(divName).innerHTML;
                    var originalContents = document.body.innerHTML;

                    document.body.innerHTML = printContents;

                    window.print();

                    document.body.innerHTML = originalContents;
                    window.location.reload();
                }
            </script>
            <h2>Visualizando Correição</h2>
            <p:tabView id="tabView" dynamic="true" cache="true">  
                <p:tab id="tba1" title="Correição">  
                    <p class="subtitle">CORREIÇÃO -  #{managerRelQuestionnaireResponse.quesResponse.notaryOffice.nome}</p>
                    <p:panel id="content" styleClass="container_24 clearfix " style="background: none;">
                        <h:form id="form" acceptcharset="utf-8">
                            <p:growl id="msg" life="5000"/>
                            <div class="grid_5" style="float:right; margin-top: -50px;">
                                <p:splitButton value="Imprimir"
                                               onclick="printDiv('respostas')" 
                                               update="@form" icon="ui-icon-print">  

                                    <p:menuitem icon="ui-icon-check" value="Conclusão"
                                                actionListener="#{managerRelConclusion.generetorReportPdf(managerRelQuestionnaireResponse.quesResponse)}" 
                                                ajax="false" title="Conclusão" update="@this"/>  
                                    <p:separator />  
                                    <p:menuitem icon="ui-icon-document" value="Comprovante"
                                                actionListener="#{managerRelCorreicao.generetorReportPdf(managerRelQuestionnaireResponse.quesResponse)}" 
                                                ajax="false" title="Comprovante" update="@this"/>
                                    <p:separator />  
                                    <p:menuitem icon="ui-icon-document" value="Edital Serventia" title="Edital Serventia"
                                                ajax="false" 
                                                actionListener="#{managerRelEdit.generetorReportPdf(managerRelQuestionnaireResponse.quesResponse)}" update="@this"/>

                                </p:splitButton> 
                            </div>
                            <p class="subtitle">Dados Gerais</p>
                            <div class="clear"/>
                            <p:outputLabel value="Município/Comarca: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.address.city.name} - #{managerRelQuestionnaireResponse.quesResponse.notaryOffice.address.city.states.sgl} " styleClass="grid_6"/>
                            <p:outputLabel value="Código: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.id} " styleClass="grid_6"/>
                            <div class="clear"/>
                            <p:outputLabel value="Denominação Serventia: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.nome} " styleClass="grid_6"/>
                            <p:outputLabel value="Natureza Serventia: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.natureOffice} " styleClass="grid_6"/>
                            <div class="clear"/>
                            <p:outputLabel value="Nome do Delegatário: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.titular} " styleClass="grid_6"/>
                            <p:outputLabel value="CPF: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.cpf} " styleClass="grid_6"/>
                            <div class="clear"/>
                            <p:outputLabel value="Ingresso na Atividade: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.admission} " styleClass="grid_6"/>
                            <p:outputLabel value="Data Posse: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.datePossesion}" styleClass="grid_6">
                                <f:convertDateTime pattern="dd/MM/yyyy"/>
                            </h:outputText>
                            <div class="clear"/>
                            <p:outputLabel value="Endereço da Serventia: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.address.street} " styleClass="grid_6"/>
                            <p:outputLabel value="Bairro: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.address.district} " styleClass="grid_6"/>
                            <div class="clear"/>
                            <p:outputLabel value="Complemento: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.address.complement} " styleClass="grid_6"/>
                            <p:outputLabel value="Cep: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.address.cep} " styleClass="grid_6"/>
                            <div class="clear"/>
                            <p:outputLabel value="CNPJ: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.cnpj} " styleClass="grid_6"/>
                            <p:outputLabel value="Telefone: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.address.phone} " styleClass="grid_6"/>
                            <div class="clear"/>
                            <p:outputLabel value="Celular: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.address.cellular} " styleClass="grid_6"/>
                            <p:outputLabel value="Email: " styleClass="grid_5"/>
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.notaryOffice.email} " styleClass="grid_6"/>
                            <div class="clear"/>

                            <p class="subtitle">Conclusão</p> 
                            <h:outputText value="#{managerRelQuestionnaireResponse.quesResponse.conclusion eq null ?
                                                   'Não há conclusão': managerRelQuestionnaireResponse.quesResponse.conclusion}" styleClass="grid_24"/>

                            <div class="clear"/>
                            <br/>
                            <p:lightBox >
                                <ui:repeat value="#{managerRelQuestionnaireResponse.quesResponse.anexo}" var="a">
                                    <h:outputLink value="show/?annex=#{a.id}" >
                                        <p:graphicImage styleClass="image grid_3" url="show/?annex=#{a.id}" style="width:100px; height:100px;
                                                        margin-right: 10px; " />
                                    </h:outputLink>
                                </ui:repeat>
                            </p:lightBox>
                            <div class="clear"/>

                            <fieldset id="respostas" style="background-color: #fff;">
                                <p class="subtitle">Respostas</p>  

                                    <ui:repeat value="#{managerRelQuestionnaireResponse.categorys}" var="c">
                                            <p:panel header="#{c.name} " style="border: 0px;" styleClass="grid_24">
                                                <ol  style="list-style-type: decimal; padding-left: 23px; color: #000000;">
                                                    <ui:repeat value="#{managerRelQuestionnaireResponse.catchResponse(c)}"  var="r">
                                                        <ui:repeat value="#{managerRelQuestionnaireResponse.catchIssues(r)}" var="i" >

                                                            <li><h:outputText value="#{i.title}" 
                                                                              style="font-weight: bold" styleClass="grid_24"/> </li>

                                                            <h:outputText value="#{r.responseOpen}"/>

                                                            <ui:repeat value="#{managerRelQuestionnaireResponse.catchOptions(r)}" var="o">
                                                                <h:outputText value="#{o.title}" styleClass="grid_20 push_1" /><br/>
                                                            </ui:repeat>

                                                            <div style="margin-top:2px;margin-bottom: 2px;"/>

                                                            <div class="clear"/>

                                                            <p:lightBox id="imgAnexo">
                                                                <ui:repeat value="#{managerRelQuestionnaireResponse.catchAnexo(r)}" var="a">
                                                                    <h:outputLink value="show/?annex=#{a.id}" title="#{a.description}" >
                                                                        <p:graphicImage styleClass="image grid_3" url="show/?annex=#{a.id}" style="width:100px; height:100px;
                                                                                        margin-right: 10px; "  />
                                                                    </h:outputLink>
                                                                </ui:repeat>
                                                            </p:lightBox>


                                                            <div class="clear"/>

                                                        </ui:repeat>
                                                    </ui:repeat>
                                                </ol>
                                            </p:panel>
                                 </ui:repeat>
                            </fieldset>
                            <br/>
                            <center>
                                <p:commandButton value="Voltar" icon="ui-icon-arrowreturnthick-1-w" actionListener="#{managerRedirect.redirect('searchEyre.xhtml')}" update="@form" immediate="true" style="font-size: 12px; font-family: sans-serif" />
                            </center>
                        </h:form>
                    </p:panel>
                </p:tab>
                <p:tab title="Determinações" >
                    <ui:include src="determinations.xhtml"/>
                </p:tab>
            </p:tabView>
        </ui:define>
    </ui:composition>
</html>

